<!DOCTYPE html>
<html  lang="zh-CN" >
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, maximum-scale=5, viewport-fit=cover">
    <title>jvm 介绍 | 陈达的博客</title>
    <meta name="description" content="jvm 基本结构 JVM构成: 代码的执行   内存管理   线程资源同步和交互机制    JVM的线程:  hotspot JVM线程与原生操作系统线程具有映射关系    虚拟机线程     周期性线程     GC线程    编译器线程    信号分发线程    JVM的内存区域 线程私有内存:栈… 虚拟机栈：会栈溢出 本地方法栈： 程序计数器：唯一不会内存溢出的地方，当前执行方法指令的字节码">
<meta property="og:type" content="article">
<meta property="og:title" content="jvm 介绍">
<meta property="og:url" content="http://itch_142.gitee.io/blog/2020/05/04/jvm/">
<meta property="og:site_name" content="陈达的博客">
<meta property="og:description" content="jvm 基本结构 JVM构成: 代码的执行   内存管理   线程资源同步和交互机制    JVM的线程:  hotspot JVM线程与原生操作系统线程具有映射关系    虚拟机线程     周期性线程     GC线程    编译器线程    信号分发线程    JVM的内存区域 线程私有内存:栈… 虚拟机栈：会栈溢出 本地方法栈： 程序计数器：唯一不会内存溢出的地方，当前执行方法指令的字节码">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-05-03T16:21:37.000Z">
<meta property="article:modified_time" content="2020-05-07T06:23:08.606Z">
<meta property="article:author" content="陈达">
<meta property="article:tag" content="总结">
<meta name="twitter:card" content="summary">

    
    <link rel="icon" href="/blog/images/favicon.ico" type="image/x-icon">

    
<link rel="stylesheet" href="/blog/css/common.min.css">



    
    
    
        <link href="//cdn.jsdelivr.net/npm/gitalk@1.4.0/dist/gitalk.min.css" rel="stylesheet">
    
    
        <link href="//cdn.jsdelivr.net/npm/lightgallery.js@1.1.3/dist/css/lightgallery.min.css" rel="stylesheet">
    
    
    
<link rel="stylesheet" href="/blog/css/iconfont.min.css">

    
<meta name="generator" content="Hexo 4.2.0"></head>

    <body>
        <header class="header header-fixture">
    <div class="profile-search-wrap flex sm:block">
        
        
        <div class="profile sm:text-center md:px-1 lg:px-3 sm:pb-4 sm:pt-6">
            <a id="avatar" role="link" href="https://github.com/itchbelief" class="inline-block lg:w-16 lg:h-16 w-8 h-8 m-2" target="_blank" rel="noopener" rel="noreferrer" >
                <img src="/blog/images/avatar.png" class="rounded-full" alt="avatar">
            </a>
            <h2 id="name" class="hidden lg:block">陈达</h2>
            <h3 id="title" class="hidden xl:block">搬砖 &amp; Coder</h3>
            
            <small id="location" class="hidden lg:block">
                <i class="iconfont icon-map-icon"></i>
                HangZhou, China
            </small>
            
        </div>
        
        
<div class="search flex-1 flex lg:inline-block sm:hidden lg:px-4 lg:mt-2 lg:mb-4 lg:w-full">
    <form id="search-form" class="my-auto flex-1 lg:border lg:border-solid lg:border-gray-200">
        <div class="input-group table bg-gray-100 lg:bg-white w-full">
            <input id="search-input" type="text" placeholder="搜索" class="inline-block w-full bg-gray-100 lg:bg-white">
            <span class="table-cell">
                <button name="search tigger button" disabled>
                    <i class="iconfont icon-search m-2"></i>
                </button>
            </span>
        </div>
    </form>
        
<script id="search-teamplate" type="text/html" data-path="/blog/content.json">
    <div>
        <div class="search-header bg-gray-400">
            <input id="actual-search-input" model="keyword" ref="input" class="inline-block w-full h-10 px-2 py-1" placeholder="搜索" type="text">
        </div>
        <div class="search-result bg-gray-200">
            {{#each searchPosts}}
            <a href="/blog/{{ path }}" class="result-item block px-2 pb-3 mb-1 pt-1 hover:bg-indigo-100">
                <i class="iconfont icon-file"></i>
                <h1 class="result-title inline font-medium text-lg">{{ title }}</h1>
                <p class="result-content text-gray-600 text-sm">{{{ text }}}</p>
            </a>
            {{/each}}
        </div>
    </div>
</script>

</div>


        <button name="menu toogle button" id="menu-toggle-btn" class="block sm:hidden p-3" role="button" aria-expanded="false">
            <i class="iconfont icon-hamburger"></i>
        </button>
    </div>
    <nav id="menu-nav" class="hidden sm:flex flex-col">
        
        
            <div class="menu-item menu-home" role="menuitem">
                <a href="/blog/.">
                    <i class="iconfont icon-home" aria-hidden="true"></i>
                    <span class="menu-title">首页</span>
                </a>
            </div>
        
        
            <div class="menu-item menu-archives" role="menuitem">
                <a href="/blog/archives">
                    <i class="iconfont icon-archive" aria-hidden="true"></i>
                    <span class="menu-title">归档</span>
                </a>
            </div>
        
        
            <div class="menu-item menu-categories" role="menuitem">
                <a href="/blog/categories">
                    <i class="iconfont icon-folder" aria-hidden="true"></i>
                    <span class="menu-title">分类</span>
                </a>
            </div>
        
        
            <div class="menu-item menu-tags" role="menuitem">
                <a href="/blog/tags">
                    <i class="iconfont icon-tag" aria-hidden="true"></i>
                    <span class="menu-title">标签</span>
                </a>
            </div>
        
        
            <div class="menu-item menu-repository" role="menuitem">
                <a href="/blog/repository">
                    <i class="iconfont icon-project" aria-hidden="true"></i>
                    <span class="menu-title">项目</span>
                </a>
            </div>
        
        
            <div class="menu-item menu-links" role="menuitem">
                <a href="/blog/links">
                    <i class="iconfont icon-friend" aria-hidden="true"></i>
                    <span class="menu-title">友链</span>
                </a>
            </div>
        
        
            <div class="menu-item menu-about" role="menuitem">
                <a href="/blog/about">
                    <i class="iconfont icon-cup" aria-hidden="true"></i>
                    <span class="menu-title">关于</span>
                </a>
            </div>
        
        
<div class="social-links lg:hidden px-6 my-2 sm:mt-48">
    
        <span class="social-item mr-2 mb-2">
            <a href="https://github.com/itchbelief" target="_blank" rel="noopener" class="lg:my-1 lg:mx-2 lg:px-4 lg:py-2 sm:py-2">
                <i class="iconfont icon-github"></i>
                <span class="menu-title hidden lg:inline">menu.github</span>
            </a>
        </span>
    
        <span class="social-item mr-2 mb-2">
            <a href="https://gitee.com/itch_142" target="_blank" rel="noopener" class="lg:my-1 lg:mx-2 lg:px-4 lg:py-2 sm:py-2">
                <i class="iconfont icon-gitee"></i>
                <span class="menu-title hidden lg:inline">menu.gitee</span>
            </a>
        </span>
    
        <span class="social-item mr-2 mb-2">
            <a href="https://t.me/itchbelief" target="_blank" rel="noopener" class="lg:my-1 lg:mx-2 lg:px-4 lg:py-2 sm:py-2">
                <i class="iconfont icon-telegram"></i>
                <span class="menu-title hidden lg:inline">menu.telegram</span>
            </a>
        </span>
    
        <span class="social-item mr-2 mb-2">
            <a href="https://twitter.com/example" target="_blank" rel="noopener" class="lg:my-1 lg:mx-2 lg:px-4 lg:py-2 sm:py-2">
                <i class="iconfont icon-twitter"></i>
                <span class="menu-title hidden lg:inline">menu.twitter</span>
            </a>
        </span>
    
        <span class="social-item mr-2 mb-2">
            <a href="/blog/atom.xml" class="lg:my-1 lg:mx-2 lg:px-4 lg:py-2 sm:py-2">
                <i class="iconfont icon-rss"></i>
                <span class="menu-title hidden lg:inline">menu.rss</span>
            </a>
        </span>
    
</div>


    </nav>
</header>

        <section class="main-section">
            
    <main class="flex-1 px-4 py-12 md:px-5 lg:px-8 lg:py-4 relative min-h-screen">
    

    <article class="content article article-archives article-type-list" itemscope="">
        <header class="article-header">
            
    
        <h1 class="article-title text-lg" itemprop="name">
            jvm 介绍
        </h1>
    



            <p class="article-meta mb-3 text-xs">
                <span class="article-date">
    <i class="iconfont icon-calendar-check"></i>
	<a href="/blog/2020/05/04/jvm/" class="article-date">
	  <time datetime="2020-05-03T16:21:37.000Z" itemprop="datePublished">5月 4</time>
	</a>
</span>

                
    <span class="article-category">
    <i class="iconfont icon-folder"></i>
    <a class="article-category-link" href="/blog/categories/java/">java</a>
  </span>


                
    <span class="article-tags">
    <i class="iconfont icon-tag"></i>
    <a class="article-tag-link" href="/blog/tags/%E6%80%BB%E7%BB%93/" rel="tag">总结</a>
  </span>


                <span class="_partial/post-comment"><i class="icon icon-comment"></i>
                    <a href="/blog/2020/05/04/jvm/#comments" class="article-comment-link">
                        评论
                    </a>
                </span>
                

            </p>
        </header>
        <div class="marked-body article-body">
            <h3 id="jvm-基本结构">jvm 基本结构</h3>
<h4 id="JVM构成">JVM构成:</h4>
<pre><code>代码的执行  
内存管理  
线程资源同步和交互机制  
</code></pre>
<h4 id="JVM的线程">JVM的线程:</h4>
<pre><code> hotspot JVM线程与原生操作系统线程具有映射关系  
 虚拟机线程   
 周期性线程   
 GC线程  
 编译器线程  
 信号分发线程  
</code></pre>
<h4 id="JVM的内存区域">JVM的内存区域</h4>
<p>线程私有内存:栈…<br>
虚拟机栈：会栈溢出<br>
本地方法栈：<br>
程序计数器：唯一不会内存溢出的地方，当前执行方法指令的字节码地址<br>
线程共享内存:堆<br>
方法区、常量池 : 常量\类信息\静态变量  ， 分代机制里面的老年代<br>
类实例区(老年代、新生代(Eden,From survivor,to survivor))<br>
直接内存:不受GC管理、NIO内存映射</p>
<h4 id="内存分代">内存分代</h4>
<p>Young（3/1） 、Eden (8/10) 、 Survivor to/form(10/1)  、Old(3/2)<br>
MinorGC 频繁执行 针对Young ,复制&gt;清空&gt;互换<br>
MajorGC 针对Old 扫描回收，标记清除算法<br>
java8永久代被’元数据区取代’，元数据使用本地内存，所以不再由MaxPermSize影响</p>
<h4 id="垃圾回收">垃圾回收</h4>
<p>GC做三件事：确定哪些是垃圾，确定什么时候回收，怎么回收<br>
确定哪些是垃圾<br>
引用计数：循环引用问题<br>
根可答性算法:不可答不等于可回收，至少两次标记<br>
垃圾算法<br>
标记清除算法（Mark-Sweep):内存碎片<br>
复制算法(copying):可用内存少<br>
标记整理算法(Mark-Compact):标记后整理存活的到内存边界，删除边界外<br>
分代收集算法:大多JVM采用，先分域 （老/新），根据不同的域选择不同算法<br>
Young GC 新生代复制算法:  eden和S_From 存活的复制到S_to,超出到Old,然后清理eden和S_From,from与to角色互换<br>
Full GC 老年代标记整理算法：<br>
Survivor 区躲过一次GC其年龄加1，默认到15年龄的对象会移到老年区域<br>
分区收集算法:将堆划分成连续不同的小区间，每个区间独立使用，好处是可以控制一次回收多少区间，根据目标停顿的时间，每次合理地回收若干个小区间(而不是整个堆), 从而减少一次 GC 所产生的停顿。</p>

        </div>
        
<blockquote class="copyright">
    <p><strong>本文链接 : </strong><a class="permalink" href="http://itch_142.gitee.io/blog/2020/05/04/jvm/">http://itch_142.gitee.io/blog/2020/05/04/jvm/</a></p>
    <p><strong>转载请注明出处</strong></p>
</blockquote>


    </article>
    
    <section id="comments">
        

        
    </section>


    

</main>


<aside style="" id="sidebar" class="aside aside-fixture">
    <div class="toc-sidebar">
        <nav id="toc" class="article-toc">
            <h3 class="toc-title">文章目录</h3>
            <ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#jvm-基本结构"><span class="toc-number">1.</span> <span class="toc-text">jvm 基本结构</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#JVM构成"><span class="toc-number">1.1.</span> <span class="toc-text">JVM构成:</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#JVM的线程"><span class="toc-number">1.2.</span> <span class="toc-text">JVM的线程:</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#JVM的内存区域"><span class="toc-number">1.3.</span> <span class="toc-text">JVM的内存区域</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#内存分代"><span class="toc-number">1.4.</span> <span class="toc-text">内存分代</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#垃圾回收"><span class="toc-number">1.5.</span> <span class="toc-text">垃圾回收</span></a></li></ol></li></ol>
        </nav>
    </div>
</aside>





        </section>
        <footer class="hidden lg:block fixed bottom-0 left-0 sm:w-1/12 lg:w-1/6 bg-gray-100 z-40">
    
    <div class="footer-social-links">
        
            <a href="https://github.com/itchbelief" target="_blank" rel="noopener">
                <i class="iconfont icon-github"></i>
            </a>
        
            <a href="https://gitee.com/itch_142" target="_blank" rel="noopener">
                <i class="iconfont icon-gitee"></i>
            </a>
        
            <a href="https://t.me/itchbelief" target="_blank" rel="noopener">
                <i class="iconfont icon-telegram"></i>
            </a>
        
            <a href="https://twitter.com/example" target="_blank" rel="noopener">
                <i class="iconfont icon-twitter"></i>
            </a>
        
            <a href="/blog/atom.xml">
                <i class="iconfont icon-rss"></i>
            </a>
        
    </div>
    
    
</footer>

        <div id="mask" class="hidden mask fixed inset-0 bg-gray-900 opacity-75 z-40"></div>
        <div id="search-view-container" class="hidden shadow-xl"></div>
        
<script src="/blog/js/dom-event.min.js"></script>

<script src="//cdn.jsdelivr.net/npm/yox@1.0.0-alpha.121/dist/standard/prod/yox.min.js"></script>


<script src="/blog/js/search.min.js"></script>


    <script src="//cdn.jsdelivr.net/npm/gitalk@1.5.2/dist/gitalk.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/blueimp-md5@2.10.0/js/md5.min.js"></script>
<script type="text/javascript">
    var gitalk = new Gitalk({
        clientID: '50bd0aac4eee32ca3180',
        clientSecret: 'cf2798687e3aff59dd8747b8d93b6cdd2763a28c',
        repo: 'blog',
        owner: 'itchbelief',
        admin: ['itchbelief'],
        id: md5(location.pathname),
        distractionFreeMode: true
    })
    gitalk.render('comments')
</script>



    <script src="//cdn.jsdelivr.net/npm/lightgallery.js@1.1.3/dist/js/lightgallery.min.js"></script>
    
<script src="/blog/js/light-gallery.min.js"></script>





    </body>
</html>
